# create a new fedimg server
# NOTE: make sure there is room/space for this server on the vmhost

- include: "/srv/web/infra/ansible/playbooks/include/virt-create.yml myhosts=fedimg:fedimg-stg"

- name: dole out the generic configuration
  hosts: fedimg;fedimg-stg
  user: root
  gather_facts: True

  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - base
  - rkhunter
  - { role: denyhosts, when: ansible_distribution_major_version|int != 7 }
  - fas_client
  - nagios_client
  - hosts
  - collectd/base
  - fedmsg/base
  - sudo
  # The proxies don't actually need to talk to these hosts so we won't bother
  # putting them on the vpn.
  #- { role: openvpn/client,
  #    when: env != "staging" }

  tasks:
  - include: "{{ tasks }}/yumrepos.yml"
  - include: "{{ tasks }}/2fa_client.yml"
  - include: "{{ tasks }}/motd.yml"

  handlers:
  - include: "{{ handlers }}/restart_services.yml"

- name: dole out the service-specific config
  hosts: fedimg;fedimg-stg
  user: root
  gather_facts: True

  roles:
  - fedmsg/hub
  - role: fedimg
    aws_keyname: fedimg-dev
    aws_keypath: /etc/pki/fedimg/fedimg-dev
    aws_pubkeypath: /etc/pki/fedimg/fedimg-dev.pub
    when: env == 'staging'
  - role: fedimg
    aws_keyname: releng-ap-northeast-1
    aws_keypath: /etc/pki/fedimg/fedimg-prod
    aws_pubkeypath: /etc/pki/fedimg/fedimg-prod.pub
    when: env != 'staging'
  - role: collectd/fedmsg-service
    process: fedmsg-hub

  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  handlers:
  - include: "{{ handlers }}/restart_services.yml"
